package temp;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.hanhai.zrb.model.project.UserProjectRef;
import com.hanhai.zrb.model.project.dto.UserProjectRefDto;

@Service("userProjectRefService")
public class UserProjectRefServiceImpl implements UserProjectRefService{
	
	@Resource
	private UserProjectRefMapper userProjectRefMapper;

	@Override
	public UserProjectRef selectByPrimaryKey(Long id) {
		return userProjectRefMapper.selectByPrimaryKey(id);
	}

	@Override
	public int deleteByPrimaryKey(Long id) {
		return userProjectRefMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(UserProjectRef record) {
		return userProjectRefMapper.insert(record);
	}

	@Override
	public int insertSelective(UserProjectRef record) {
		return userProjectRefMapper.insertSelective(record);
	}

	@Override
	public int updateByPrimaryKeySelective(UserProjectRef record) {
		return userProjectRefMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKey(UserProjectRef record) {
		return userProjectRefMapper.updateByPrimaryKey(record);
	}

	
	@Override
	public List<UserProjectRef> queryRefByCondition(Date publishTime,boolean forward,Integer userId,Integer refType,Integer limit){
		UserProjectRefDto userProjectRefDto = new UserProjectRefDto();
		userProjectRefDto.setUserId(userId);;
		userProjectRefDto.setRefType(refType);
		if(forward){
			userProjectRefDto.setStartTime(publishTime);
		}else{
			userProjectRefDto.setEndTime(publishTime);
		}
		userProjectRefDto.setPageNum(1);
		userProjectRefDto.setPageSize(limit);
		
		return userProjectRefMapper.queryRefByCondition(userProjectRefDto);
	}
	
	@Override
	public List<UserProjectRef> queryRefByConditions(UserProjectRefDto userProjectRefDto){
		return userProjectRefMapper.queryRefByCondition(userProjectRefDto);
    }
	
	@Override
	public int deleteByProjectId(Integer projectId,Integer refType){
		return userProjectRefMapper.deleteByProjectId(projectId, refType);
	}

}
